<?php
/**
 * _fwiload is loader ultility. Use it if you don't want to load manual in difficult.
 *
 * @author trunghpb
 */
class _fwiload {
    private static $conf = null;
    
    public static function package($name, $loadFile = false){
        if ($loadFile === false){
            include_once _fwiPACKAGE_PATH_.$name.DIRECTORY_SEPARATOR.$name.'.php';
        }else{
            include_once _fwiPACKAGE_PATH_.$name.DIRECTORY_SEPARATOR.$loadFile.'.php';
        }

    }

    public static function lib($name, $loadFile = false){
        if ($loadFile === false){
            include_once _fwiLIB_PATH_.$name.DSR.$name.'.php';
        }else{
            include_once _fwiLIB_PATH_.$name.DSR.$loadFile.'.php';
        }

    }

    public static function js($filePath){
        return _fwia::BaseURL().'js/'.$filePath;
    }
    
    public static function loadView($name, $params = false){
        include_once _fwia::AppPath().DIRECTORY_SEPARATOR.'server'.DIRECTORY_SEPARATOR.'view'.DIRECTORY_SEPARATOR.$name.'.php';
        if ($params === false){
            return new $name();
        }
    }

    public static function loadLogic($name, $param = false){
        include_once _fwia::AppPath().'server'.DIRECTORY_SEPARATOR.'helper'.DIRECTORY_SEPARATOR.$name.'.php';
        if ($param === false){
            return new $name();
        }
    }

    public static function includeLogic($name){
        include_once _fwia::AppPath().'server'.DIRECTORY_SEPARATOR.'helper'.DIRECTORY_SEPARATOR.$name.'.php';
    }

    public static function loadConfig($name, $key = false){
        $filePath = _fwia::AppPath().DSR.'server'.DSR.'helper'.DSR.$name.'.ini';
        if (self::$conf == null){
            self::$conf = parse_ini_file($filePath, true);
        }
        return $key === false ? self::$conf : self::$conf[$key];
    }
}

?>
